#ifndef _TESTCASE_H_
#define _TESTCASE_H_

#include "main.h"

typedef enum _cmd_state{
    CMD_IDLE,
    CMD_WRITING,
    CMD_READING,
    CMD_COMPLETED
}CMD_STATE;

typedef struct _cmd_info{
    ULONG     StartOffset;      // in units of SECTOR_SZ (0 or 512)
    ULONG     CurrentOffset;    // in units of SECTOR_SZ (0 or 512)
    ULONG     LoopNum;
    ULONG     MagicNum;
    ULONG     Crc;
    CMD_STATE State;
}CMD_INFO, *PCMD_INFO;

typedef STATUS (*PCMD_ROUTINE)( struct _cmd_info_flash* CmdInfoFlash, struct _common_cmd_info* );

typedef struct _common_cmd_info{
    ULONG   MemBASw;
    ULONG   StageLength;      // in units of SECTOR_SZ.
    ULONG   MaxNumPerLoop;    // the maximum of CurrentIndex.
    ULONG   MaxLoopNum;
    ULONG   CompletedBitmap;
}COMMON_CMD_INFO, *PCOMMON_CMD_INFO;

typedef struct _cmd_info_flash{
    UCHAR           Tag;
    ULONG           StartOffset;      // in units of SECTOR_SZ (0 or 512)
    ULONG           CurrentIndex;    // in units of StageLength.
    ULONG           LoopNum;
    ULONG           MagicNum;
    ULONG           Crc;
    PHOST_CMD       HostCmd;
    PCMD_ROUTINE    pHandler;
    CMD_STATE       State;
}CMD_INFO_FLASH, *PCMD_INFO_FLASH;
/*
 * read/write test.
 *
 * Each loop includes that "CmdNum" sequential write simultaneously folllowed by
 * "CmdNum" sequential read simultaneously.
 * Once one read operation completes, next loop of the command will issue
 * until the times of loop completes.
 *
 * LoopNum: indicates how many loops to run.
 * CmdNum : indicates how many commands will be issued simultaneously. The maximum value is 32.
 * Length : indicates how many data each command transfers, in units of bytes.
 */
STATUS TestCaseAsyncRWDiskAB( PAHCI_EXT AhciExt, UCHAR DiskIndex, UCHAR CmdNum, ULONG LoopNum, ULONG Length );
STATUS TestCaseSyncEWRDiskCOnce( PAHCI_EXT AhciExt, ULONG Offset, ULONG Length);
STATUS TestCaseAsyncEWRDiskC( PAHCI_EXT AhciExt, UCHAR CmdNum, ULONG LoopNum, ULONG Length);

/*
 * callback functions for TestCaseAsyncEWRDiskC
 */
STATUS AsyncEraseFlash( PCMD_INFO_FLASH CmdInfoFlash, PCOMMON_CMD_INFO CommonInfo );
STATUS AsyncWriteFlash( PCMD_INFO_FLASH CmdInfoFlash, PCOMMON_CMD_INFO CommonInfo );
STATUS AsyncReadFlash( PCMD_INFO_FLASH CmdInfoFlash, PCOMMON_CMD_INFO CommonInfo );
STATUS CheckDataForReadFlash(PCMD_INFO_FLASH CmdInfoFlash, PCOMMON_CMD_INFO CommonInfo );
STATUS NullFunction( PCMD_INFO_FLASH CmdInfoFlash, PCOMMON_CMD_INFO CommonInfo );

#endif // _TESTCASE_H_

